<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:composite="http://java.sun.com/jsf/composite">
<h:head>

	<title>This will not be present in rendered output</title>

</h:head>

<h:body>

	<composite:interface name="simplePaginator"
		displayName="Simple DataValve Paginator">

		<composite:attribute required="true" name="paginator"
			type="org.fluttercode.datavalve.Paginator"
			shortDescription="The paginator that is used to provide data and pagination state for this component." />


		<composite:attribute required="false" name="pageTextClass"
			shortDescription="Style class for the page x of y message" />

		<composite:attribute required="false" name="buttonClass"
			shortDescription="Style class for the navigation buttons" />
			
		<composite:attribute required="false" name="ajaxEnabled"
			type="java.lang.Boolean" default="False"
			shortDescription="Indicates if ajax should be used to update the page when the user navigates the data." />

		<composite:attribute required="false" name="ajaxRender" default="@all"
			shortDescription="Value used for the render parameter in the ajax processing. Only needed it if ajaxEnabled=true" />

		<composite:attribute required="false" name="ajaxExecute"
			default="@form"
			shortDescriptio="Value used for the execute parameter in the ajax processing. Only needed it ajaxEnabled=true" />

		<composite:attribute required="false" name="holdState"
			type="java.lang.Boolean" default="True"
			shortDescription="If true, the paginator will hold the pagination state and send it back to the paginator when a postback occurs. Can be used for stateless pagination without using page parameters if the source paginator has a stateless scope." />

		<composite:attribute required="false" name="showPageNumbers"
			default="True"
			shortDescriptio="Indicates whether the page x of y text is shown in the paginator" />

		<composite:attribute name="captionFirst" default="First"
			shortDescription="Caption for the first button" />

		<composite:attribute name="captionPrevious" default="Previous"
			shortDescription="Caption for the previous button" />

		<composite:attribute name="captionNext" default="Next"
			shortDescription="Caption for the next button" />

		<composite:attribute name="captionLast" default="Last"
			shortDescription="Caption for the last button" />


	</composite:interface>

	<composite:implementation>
		<h:panelGroup rendered="#{cc.attrs.holdState}">
			<h:inputHidden value="#{cc.attrs.paginator.firstResult}" />
			<h:inputHidden value="#{cc.attrs.paginator.maxRows}" />
			<h:inputHidden value="#{cc.attrs.paginator.firstResult}" />
			<h:inputHidden value="#{cc.attrs.paginator.orderKey}" />
			<h:inputHidden value="#{cc.attrs.paginator.orderAscending}" />
		</h:panelGroup>

		<h:panelGrid styleClass="paginator" columns="5">
			<f:ajax execute="#{cc.attrs.ajaxExecute}"
				render="#{cc.attrs.ajaxRender}" rendered="#{cc.attrs.ajaxEnabled}"
				disabled="#{not cc.attrs.ajaxEnabled}">
				

				<h:commandButton value="#{cc.attrs.captionFirst}"
					class="#{cc.attrs.buttonClass}"
					action="#{cc.attrs.paginator.first}" />

				<h:commandButton value="#{cc.attrs.captionPrevious}"
					class="#{cc.attrs.buttonClass}"
					action="#{cc.attrs.paginator.previous}" />


				<h:outputText
					value="Page #{cc.attrs.paginator.page} of #{cc.attrs.paginator.pageCount}"
					styleClass="#{cc.attrs.pageTextClass}" style="margin-right : 28px"
					rendered="#{cc.attrs.showPageNumbers}" />
				<h:panelGroup rendered="#{not cc.attrs.showPageNumbers}" />

				<h:commandButton value="#{cc.attrs.captionNext}"
					action="#{cc.attrs.paginator.next}" class="#{cc.attrs.buttonClass}" />


				<h:commandButton value="#{cc.attrs.captionLast}"
					action="#{cc.attrs.paginator.last}" class="#{cc.attrs.buttonClass}" />
			</f:ajax>
		</h:panelGrid>
	</composite:implementation>

</h:body>

</html>
